home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / J A V A / Java Development Kit V1.2 / jdk12-win32(1).exe / data1.cab / demos / demo / jfc / Java2D / GlobalPanel.java < prev    next >
Encoding:
Java Source  |  1998-12-01  |  1.8 KB  |  56 lines

  1. /*
  2.  * @(#)GlobalPanel.java    1.9 98/09/21
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15.  
  16. import java.awt.GridBagLayout;
  17. import java.awt.BorderLayout;
  18. import javax.swing.JPanel;
  19. import javax.swing.JTabbedPane;
  20. import javax.swing.border.*;
  21. import javax.swing.event.ChangeEvent;
  22. import javax.swing.event.ChangeListener;
  23.  
  24.  
  25. /**
  26.  * Panel that holds the Demo groups, Controls and Monitors for each tab.
  27.  * It's a special "always visible" panel for the Controls, MemoryMonitor &
  28.  * PerformanceMonitor.
  29.  */
  30. public class GlobalPanel extends JPanel implements ChangeListener {
  31.  
  32.  
  33.     public GlobalPanel() {
  34.         setLayout(new BorderLayout());
  35.         JPanel p = new JPanel(new GridBagLayout());
  36.         EmptyBorder eb = new EmptyBorder(5,0,5,5);
  37.         BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
  38.         p.setBorder(new CompoundBorder(eb,bb));
  39.         Java2Demo.addToGridBag(p,Java2Demo.controls,0,0,1,1,0,0);
  40.         Java2Demo.addToGridBag(p,Java2Demo.memorymonitor,0,1,1,1,0,0);
  41.         Java2Demo.addToGridBag(p,Java2Demo.performancemonitor,0,2,1,1,0,0);
  42.         add(p, BorderLayout.EAST);
  43.     }
  44.  
  45.     private int index;
  46.  
  47.     public void stateChanged(ChangeEvent e) {
  48.         Java2Demo.group[index].shutDown(Java2Demo.group[index].getPanel());
  49.         remove(Java2Demo.group[index]);
  50.         index = Java2Demo.tabbedPane.getSelectedIndex();
  51.         add(Java2Demo.group[index]);
  52.         Java2Demo.group[index].setup(false);
  53.         validate();
  54.     }
  55. }
  56.